<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Hello World!</title>
    <!-- https://electronjs.org/docs/tutorial/security#csp-meta-tag -->
    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
  </head>
  <body>
    <script>
      const { createWorker } = require('tesseract.js');
      const path = require('path');

      const worker = createWorker({
        cachePath: path.join(__dirname, 'lang-data'),
        logger: m => console.log(m),
      });

      (async () => {
        await worker.load();
        await worker.loadLanguage('eng');
        await worker.initialize('eng');
        const { data: { text } } = await worker.recognize(path.join(__dirname, 'images', 'testocr.png'));
        console.log(text);
        await worker.terminate();
      })();
    </script>
  </body>
</html>
